package clueless.client;

import java.awt.Color;
import java.awt.GridLayout;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.LineBorder;

public class GuiRoom extends GuiPanel {

	 // 0 = none
	 // 1 = left
	 // 2 = right	
	private int secretPassage = 0;
	
	// 0 = down
	// 1 = up
	private int characterUpOrDown = 0;
	private JPanel secretPassagePanel = new JPanel();
	
	void setSecretPassage(int passage) {
		secretPassage = passage;
	}
	
	void makeSecretPassage()
	{
		secretPassagePanel.setLayout(new GridLayout(1,3));
		if (secretPassage == 0) {
			secretPassagePanel.add(new JPanel());
			secretPassagePanel.add(new JPanel());
			secretPassagePanel.add(new JPanel());
		} else if (secretPassage == 1) {
			JPanel passage = new JPanel();
			passage.setBorder(new LineBorder(Color.black));
			secretPassagePanel.add(passage);
			secretPassagePanel.add(new JPanel());
			secretPassagePanel.add(new JPanel());
		} else {
			secretPassagePanel.add(new JPanel());
			secretPassagePanel.add(new JPanel());
			JPanel passage = new JPanel();
			passage.setBorder(new LineBorder(Color.black));
			secretPassagePanel.add(passage);
		}
	}
	
	void makeTopPanel() {
		if (characterUpOrDown == 0) {
			makeSecretPassage();
			this.add(secretPassagePanel);
		} else {
			makeCharacterPanel(0);
			this.add(getCharacterPanel());
		}
	}
	

	
	void makeBottomPanel() {
		if (characterUpOrDown == 1) {
			makeSecretPassage();
			this.add(secretPassagePanel);
		} else {
			makeCharacterPanel(0);
			this.add(getCharacterPanel());
		}
	}
	
	
	void init(String room) {
		
		this.setBorder(new LineBorder(Color.black));
		this.setLayout(new GridLayout(3,1));
		makeTopPanel() ;
		
		//this.add(new JPanel());
		this.add(new JLabel(room,JLabel.CENTER));
		//this.add(new JPanel());
		
		makeBottomPanel();
		//this.setMrGreen();
		//this.setMrsPeacock();
	}

	// passage = 0 == no secret passage
	// passage = 1 == left secret passage
	// passage = 2 == right secret passage
	// character = 0 == character on bottom
	// character = 1 == character on top
	public GuiRoom(String room, int passage, int character) {
		super();
		
		secretPassage = passage;
		characterUpOrDown = character;
		
		setSecretPassage(passage);
		init(room);
	}
	
	

}
